package com.lyj.knife4j.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger配置
 * @author: 李亚杰
 * @version: 1.0
 * @date: 2021/8/16 11:18
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * Swagger2 API
     * @author: liyajie
     * @date: 2021/2/19 16:08
     * @param
     * @return: springfox.documentation.spring.web.plugins.Docket
     * @exception:
     * @update:
     * @updatePerson:
     */
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(this.apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.lyj.knife4j"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * API 接口描述
     * @author: liyajie
     * @date: 2021/2/19 16:08
     * @param
     * @return: springfox.documentation.spring.web.plugins.Docket
     * @exception:
     * @update:
     * @updatePerson:
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .contact("李亚杰<17710557864@163.com>")
                .title("RestAPI文档")
                .description("RestAPI文档")
                .version("1.0.0-DEV")
                .build();
    }
}

